<?php use_helper('Form') ?>
<script>
$(document).ready(function() {
     $.ajax({
      type: "POST",
      url: "/backend.php/razred/ajaxList",
      data: "skola_id=" + $('#ucenik_skola_id').val(),
      success: function(msg){
        $('#ucenik_razred_id').html(msg);
        $('#ucenik_razred_id').val('<?php echo $sf_request->getParameter('razred_id') ?>');
      }
    });
  });
</script>

<style>
  td.nul_pad{
     padding: 3px 0 0 3px;
  }
</style>

<div style="margin-top: 20px;">
<form method="post">
<table>
  <tr>
    <td colspan="2">
      <label>Škola</label>
      <select name="skola_id" id="ucenik_skola_id">
        <option value="">Izaberi</option>
        <?php echo options_for_select($skolas, $sf_request->getParameter('skola_id')) ?>
      </select>
    </td>
    <td colspan="2">
      <label>Razred</label>
      <select name="razred_id" id="ucenik_razred_id">
        <option value="">Izaberi</option>
      </select>
    </td>
  </tr>

  <tr>
    <td>
      <label>Prezime oca</label>
    </td>
    <td>
      <input type="text" name="prezime_oca" id="prezime_oca" value="<?php echo $sf_request->getParameter('prezime_oca') ?>" />
    </td>
    <td>
      <label>Ime oca</label>
    </td>
    <td>
      <input type="text" name="ime_oca" id="ime_oca" value="<?php echo $sf_request->getParameter('ime_oca') ?>" />
    </td>
  </tr>

  <tr>
    <td>
      <label>Prezime majke</label>
    </td>
    <td>
      <input type="text" name="prezime_majka" id="prezime_majka" value="<?php echo $sf_request->getParameter('prezime_majka') ?>" />
    </td>
    <td>
      <label>Ime majke</label>
    </td>
    <td>
      <input type="text" name="ime_majka" id="ime_majka" value="<?php echo $sf_request->getParameter('ime_majka') ?>" />
    </td>
  </tr>
  <tr>
    <td colspan="4">
      <button type="submit">Traži</button>
      <span id="indicator" class="hide" style="margin-left: 5px;"><?php echo image_tag("ajax-loading_2.gif", array("alt" => "Čuva se")) ?></span>
    </td>
  </tr>
</table>
</form>

</div>

<table style="margin: 10px 0 0 10px;" class="form_holder">
<tr>
    <th>RID</th>
    <th>Ime Učenika</th>
    <th>Ime oca</th>
    <th>Ime majke</th>
    <th>Članarina</th>
    <th>Kredit</th>
    <th>Mobilni</th>
    <th>Tst</th>
    <th>Soc</th>
    <th>Oce</th>
    <th>Izo</th>
    <th>Dom</th>
    <th>Obv</th>
    <th>Obt</th>
    <th colspan="3">Akcije</th>
  </tr>
<?php foreach($roditeljs as $roditelj)
{
   $roditelj_id = $roditelj->getColumn('RoditeljId');
   $ucenik_id = $roditelj->getColumn('UcenikId');
?>
  <tr>
    <td><?php echo $roditelj_id ?></td>
    <td><?php echo $uceniks_arr[$ucenik_id] ?></td>
    <td><?php echo $roditelj->getPrezime().' '.$roditelj->getIme() ?></td>
    <td><?php echo $roditelj->getColumn('PrezimeMajka').' '.$roditelj->getColumn('ImeMajka') ?></td>
    <td class="nul_pad">
      <input type="text" value="<?php echo ($roditelj->getColumn('Clanarina'))?Functions::datumSr($roditelj->getColumn('Clanarina')):'' ?>" onfocus="showCalendarControl(this);" id="dat_<?php echo $roditelj_id ?>" name="" size="8" autocomplete="off" />
      <img onclick='clanarinaDo("<?php echo $roditelj_id ?>")' src="/images/save_button.gif" alt="sačuvaj" />
    </td>
    <td class="nul_pad">
      <input type="text" value="<?php echo $roditelj->getColumn('Kredit') ?>" id="cre_<?php echo $roditelj_id ?>" name="" size="8" autocomplete="off" />
      <img onclick='credit("<?php echo $roditelj_id ?>")' src="/images/save_button.gif" alt="sačuvaj" />
    </td>
    <td class="nul_pad"  style="padding-top: 5px;">
      <input type="text" value="<?php echo $roditelj->getMobilni() ?>" id="mob_<?php echo $roditelj_id ?>" name="" size="10" maxlength="10" autocomplete="off" onchange='mobilni("<?php echo $roditelj_id ?>")' />
    </td>
    <td class="nul_pad">
      <a href='javascript:bool("<?php echo $roditelj_id ?>", "tst");'>
        <img style="border: 0px none ;" id="tst_<?php echo $roditelj_id ?>" src="/images/<?php echo ($roditelj->getColumn('Tst')) ? 'v' : 'x' ?>.gif" />
      </a>
    </td>
    <td class="nul_pad">
      <a href='javascript:bool("<?php echo $roditelj_id ?>", "soc");'>
        <img style="border: 0px none ;" id="soc_<?php echo $roditelj_id ?>" src="/images/<?php echo ($roditelj->getColumn('Soc')) ? 'v' : 'x' ?>.gif" />
      </a>
    </td>
    <td class="nul_pad">
      <a href='javascript:bool("<?php echo $roditelj_id ?>", "oce");'>
        <img style="border: 0px none ;" id="oce_<?php echo $roditelj_id ?>" src="/images/<?php echo ($roditelj->getColumn('Oce')) ? 'v' : 'x' ?>.gif" />
      </a>
    </td>
    <td class="nul_pad">
      <a href='javascript:bool("<?php echo $roditelj_id ?>", "izo");'>
        <img style="border: 0px none ;" id="izo_<?php echo $roditelj_id ?>" src="/images/<?php echo ($roditelj->getColumn('Izo')) ? 'v' : 'x' ?>.gif" />
      </a>
    </td>
    <td class="nul_pad">
      <a href='javascript:bool("<?php echo $roditelj_id ?>", "dom");'>
        <img style="border: 0px none ;" id="dom_<?php echo $roditelj_id ?>" src="/images/<?php echo ($roditelj->getColumn('Dom')) ? 'v' : 'x' ?>.gif" />
      </a>
    </td>
    <td class="nul_pad">
      <a href='javascript:bool("<?php echo $roditelj_id ?>", "obv");'>
        <img style="border: 0px none ;" id="obv_<?php echo $roditelj_id ?>" src="/images/<?php echo ($roditelj->getColumn('Obv')) ? 'v' : 'x' ?>.gif" />
      </a>
    </td>
    <td class="nul_pad">
      <a href='javascript:bool("<?php echo $roditelj_id ?>", "obt");'>
        <img style="border: 0px none ;" id="obt_<?php echo $roditelj_id ?>" src="/images/<?php echo ($roditelj->getColumn('Obt')) ? 'v' : 'x' ?>.gif" />
      </a>
    </td>
    <td class="nul_pad">
      <a id="<?php echo $ucenik_id ?>" href='javascript:void(0);' onclick="bracaSestre(this.id)">B/S</a>
    </td>
    <td class="nul_pad">
      <a id="upl_<?php echo $ucenik_id ?>" href='javascript:void(0);' onclick="pregledUplata(this.id)">UPL</a>
    </td>
    <td class="nul_pad">
      <img id="<?php echo $roditelj_id ?>" onclick="stampajKorPodatke(this.id)" src="/images/printButton.png" alt="štampaj" />
    </td>
  </tr>
<?php }?>
</table>